package main

// we can iterate over values received from a channel

import "fmt"

func main() {
	queue := make(chan string, 2)
	queue <- "one"
	queue <- "two"
	// it's possible to close a non-empty channel but still have
	// the remaining values be received
	close(queue)

	// iterate over 2 values in the queue channel
	// Because we closed the channel above, the iteration
	// terminates after received the 2 elements.
	for elem := range queue {
		fmt.Println(elem)
	}
}
